package com.example.demo.study;

public class Study13 {

    public static <E> void printAll(E[] elements) {
        for (E e: elements) {
            System.out.println("--"+e);
        }
    }
    public class MyClass<T> {
       private T name;
       public void add(T t){
           this.name = t;
       }
       public T get() {
           return name;
       }
    }

    public static void main(String[] args) {



        Integer [] numbers = {1, 2, 3, 4, 5};
        String [] strings = {"a", "b", "c", "d"};
        printAll(numbers); // 自动识别为 Integer[]
        printAll(strings); // 自动识别为 String[]


    }
}
